####
library(dplyr)
library(car)


S2_data <- read.csv("" , header = TRUE, sep = ";")
str(S2_data)

# First we estimate a model with only the treatment/notreatment weeks

m1 <- lm(Compliance ~ NoTreat_Week2 + NoTreat_Week3 + NoTreat_Week4 + Treat_Week2 + Treat_Week3 + Treat_Week4, data = S2_data)
summary(m1)

linearHypothesis(m1, "NoTreat_Week2 = NoTreat_Week3") #is the effect of week2 different from week3 for the no-treatment group?
linearHypothesis(m1, "NoTreat_Week2 = NoTreat_Week4") #is the effect of week2 different from week4 for the no-treatment group?
linearHypothesis(m1, "NoTreat_Week3 = NoTreat_Week4") #is the effect of week3 different from week4 for the no-treatment group?
linearHypothesis(m1, "Treat_Week2 = Treat_Week3") #is the effect of week2 different from week3 for the treatment group?
linearHypothesis(m1, "Treat_Week2 = Treat_Week4") #is the effect of week2 different from week4 for the treatment group?
linearHypothesis(m1, "Treat_Week3 = Treat_Week4") #is the effect of week3 different from week4 for the treatment group?
